//
//  TTAlertInputView.m
//  TaoTuo
//
//  Created by admin on 2019/12/19.
//  Copyright © 2019 admin. All rights reserved.
//

#import "TTAlertInputView.h"

@interface TTAlertInputView ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UITextField *textField;

@property (nonatomic, copy) ConfirmBlock confirmBlock;

@end

@implementation TTAlertInputView

+ (instancetype)createInputViewWithTitle:(NSString *)title content:(nullable NSString *)content confirmBlock:(nonnull ConfirmBlock)confirmBlock
{
    TTAlertInputView *inputView = [self createViewFromNib];
    inputView.titleLabel.text = title;
    inputView.textField.text = content;
    inputView.confirmBlock = confirmBlock;
    
    inputView.layer.cornerRadius = 10;
    inputView.width = SCREEN_WIDTH - 60;
    
    inputView.textField.layer.borderColor = [UIColor grayColor].CGColor;
    inputView.textField.layer.borderWidth = 0.5;
    inputView.textField.layer.cornerRadius = 5;
    
    return inputView;
}

- (IBAction)cancelAction:(id)sender {
    
    [self hideView];
    
    
}


- (IBAction)confirmAction:(id)sender {
    
    if (self.confirmBlock) {
        self.confirmBlock(self.textField.text);
    }
    
    [self hideView];
}


@end
